import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CupertinoNavigationBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        navigationBar:_cupertinoNavigationBar(),
        child:Center(
          child: Text('页面内容'),
        )
    );
  }

  CupertinoNavigationBar _cupertinoNavigationBar() {
    return CupertinoNavigationBar(
      //左侧控件
      leading: Icon(Icons.arrow_back),
      //是否添加默认leading,当leading为空会默认添加一个返回按钮
      automaticallyImplyLeading: true,
      //是否添加默认middle 如果 middle 为空，且当前 route 为 CupertinoPageRoute，会默认填充 route.title
      automaticallyImplyMiddle: true,
      //当leading为空，且automaticallyImplyLeading==true，会出现在默认返回箭头右边的文字
      previousPageTitle: 'back',
      //中间标题组件
      middle: Text('CupertinoNavigationBar'),
      //右边组件
      trailing: Icon(Icons.add),
      //边框
      border: Border(
          bottom: BorderSide(color: Colors.red,
              width: 1)
      ),
      //背景色
      backgroundColor: Colors.pink,
      //上方电量，时间，wifi等状态栏颜色
      brightness: Brightness.light,
      //内边距
      padding: EdgeInsetsDirectional.only(
        start: 15,
          bottom: 0,
        end: 15
      ),

    );
  }

}